﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 第五次作业第一题
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        /*判断某数是否是素数*/
        static bool isPrime(int number)
        {
            try
            {
                if (number == 1)
                    return false;
                for (int i = 2; i <= Math.Sqrt(number); i++)
                {
                    if (number % i == 0)
                        return false;
                }
                return true;
            }
            catch {
                return false;
            };
        }
        /*点击开始按纽触发事件*/
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {//两层循环遍历
                for (int i = 6; i < 101; i = i + 2)
                {
                    for (int j = 2; j < i / 2 + 1; j++)
                    {
                        if (isPrime(j) && isPrime(i - j))
                        {
                            outPut.Text += (i.ToString() + " = " + j.ToString() + " + " + (i - j).ToString() + "\t");
                            break;
                        }
                    }
                }
            }
            catch { };
        }
    }
}
